#include <bits/stdc++.h>

using namespace std;
using ll = long long;

const int MAXN = 200'005;

int t;
int n;
int a[MAXN];
map<int, int> mp;

void solve() {
    cin >> n;
	mp.clear();
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    	mp[a[i]]++;
    }

	ll base = 0;

	vector<int> odd, even;
	for (auto [x, c] : mp) {
		base += (ll) x * (c / 2);
		if (c % 2 == 1) {
			odd.push_back(x);
		} else if (c >= 2) {
			even.push_back(x);
		}
	}

	if (base == 0) {
		cout << 0 << '\n';
		return;
	}

	ll ans = 0;
	for (const int x : odd) {
		if (2 * base > x) {
			ans = max(ans, 2 * base + x);
		}
	}
	for (int i = 1; i < (int)odd.size(); i++) {
		if (odd[i - 1] + 2 * base > odd[i]) {
			ans = max(ans, odd[i - 1] + 2 * base + odd[i]);
		}
	}

	for (int x : even) {
		if (base - x > 0) {
			ans = max(ans, 2 * base);
		}
	}

    cout << ans << endl;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int t;
	cin >> t;
	while (t-- > 0) {
		solve();
	}
	return 0;
}
